"""
File: example_2.py
Project: 活动2_破译密码
File Created: 2020/02/11 20:03:27
Author: Dunmore (fovd2020@outlook.com)
------------------------------------------------------------
Description:
1.2.2 活动2 破译密码
根据输入的数字，参照对应的密码手册（Excel表格），完成密码的输出
------------------------------------------------------------
"""
import os
import xlrd

# 获取文件所在的路径
currrent_dir = (
    os.path.dirname(__file__) if "__file__" in locals() else os.getcwd()
)

workbook = xlrd.open_workbook(os.path.join(currrent_dir, "密码手册.xlsx"))
sheet = workbook.sheet_by_index(0)

# input_str = "746385"
input_str = input(r"请输入密码数字(最多10位)：")
print("破译后的内容为：", end="")
for col, i in enumerate(input_str):
    print(sheet.cell_value(rowx=int(i) - 1, colx=col), end="")
